Expand description
A utility for recursively measuring the size of an object
This contains the DeepSizeOf
trait, and re-exports
the DeepSizeOf
derive macro from deepsize_derive
use deepsize::DeepSizeOf;
#[derive(DeepSizeOf)]
struct Test {
a: u32,
b: Box<u8>,
}
let object = Test {
a: 15,
b: Box::new(255),
};
// The stack size of the struct:
// The size of a u32 (4)
// 4 bytes padding (64 bit only)
// The stack size of the Box (a usize pointer, 32 or 64 bits: 4 or 8 bytes)
// + the size of a u8 (1), the Box's heap storage
#[cfg(target_pointer_width = "64")]
assert_eq!(object.deep_size_of(), 17);
#[cfg(target_pointer_width = "32")]
assert_eq!(object.deep_size_of(), 9);
Macros§
- A macro to generate an impl for types with known inner allocation sizes.
Structs§
- The context of which references have already been seen. This should only be used in the implementation of the
deep_size_of_children
function, and (eventually, when this reaches 0.2) will not be able to be constructed, and only obtained from inside the function.
Traits§
- A trait for measuring the size of an object and its children